export const initHome = async () => {
  // 可以取消这两行代码
  if (!window.jQuery) return
  const $ = window.jQuery

  await Promise.all([
    // owlcarousel
    loadScript('/html/assets/js/owl.carousel.js'),
    // stats number counter
    loadScript('/html/assets/js/jquery.waypoints.min.js'),
    loadScript('/html/assets/js/jquery.countup.js')
  ])

  // script for banner slider 轮播图
  $(document).ready(function () {
    $('.owl-one').owlCarousel({
      loop: true,
      margin: 0,
      nav: false,
      responsiveClass: true,
      autoplay: true,
      autoplayTimeout: 5000,
      autoplaySpeed: 1000,
      autoplayHoverPause: false,
      responsive: {
        0: {
          items: 1
        },
        480: {
          items: 1
        },
        667: {
          items: 1
        },
        1000: {
          items: 1
        }
      }
    })
  })

  // script for 计数器
  $('.counter').countUp();

  // script for tesimonials carousel slider
  $(document).ready(function () {
    $("#owl-demo1").owlCarousel({
      loop: true,
      margin: 20,
      nav: false,
      responsiveClass: true,
      responsive: {
        0: {
          items: 1,
          nav: false
        },
        768: {
          items: 2,
          nav: false
        },
        1000: {
          items: 3,
          nav: false,
          loop: false
        }
      }
    })
  })
}